﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Threading;
using Microsoft.Xna.Framework;

namespace girapong
{
    public abstract class solid
    {
        public Vector2 speed { get; set; }
        public DispatcherTimer dtSpeed;
        public System.Windows.Point position;
        protected screen screenReference;
        protected rally rallyReference;
        public static double sqrt = 1.414213562373095;

        public Boolean rectangleIntersection(double izqForma, double longForma, double topForma, double hForma,
            System.Windows.Shapes.Rectangle rE)
        {
            double bLeft = izqForma;
            double b_rELeft = rE.Margin.Left;
            double bRight = bLeft + longForma;
            double b_reRight = b_rELeft + rE.Width;

            double bTop = topForma;
            double b_rETop = rE.Margin.Top;

            double bBottom = bTop + hForma;
            double b_reBottom = b_rETop + rE.Height;

            return ((((bLeft >= b_rELeft) && (bLeft <= b_reRight)) || ((bRight >= b_rELeft) && (bRight <= b_reRight)))
                && (((bTop >= b_rETop) && (bTop <= b_reBottom)) || ((bBottom >= b_rETop) && (bBottom <= b_reBottom))));
        }
        public int clashToBlockWhileMovement(double leftShape, double longShape, double topShape, double hShape,
            System.Windows.Shapes.Rectangle r) // 0 put out Y, 1 put out X
        {

            double circleSubTop = topShape - 15;
            double circleBottom = topShape + hShape;
            double circleRight = leftShape + longShape;
            double rRight = r.Margin.Left + r.Width;
            double rBottom = r.Margin.Top + r.Height;
            if (((circleBottom >= r.Margin.Top)
                                   && (circleBottom <= (r.Margin.Top + 15))
                                   && (circleRight >= r.Margin.Left)
                                   && (circleRight <= rRight)
                                   && (speed.Y > 0))
                                   ||
                                   ((circleSubTop <= rBottom)
                                   && (circleBottom >= rBottom)
                                   && (circleRight >= r.Margin.Left)
                                   && (circleRight <= rRight)
                                   && (speed.Y < 0)))
            {
                return 0;
            }
            else
                if (((circleBottom >= r.Margin.Top)
                    && (topShape <= rBottom))
                    &&
                   ((
                    (circleRight >= r.Margin.Left)
                    && (circleRight <= r.Margin.Left + 15)
                    && (speed.X > 0)
                    )
                    ||
                    (
                    leftShape <= rRight)
                    && (circleRight >= rRight)
                    && (speed.X < 0)
                    ))
                {
                    return 1;
                }
            return -1;
        }
    }
}